/**
 */
package ConnectorGenerator.ConnectorArchitecture.impl;

import ConnectorGenerator.Auxiliary.impl.FirstClassEntityImpl;

import ConnectorGenerator.CommunicationStyle.CommunicationStyle;

import ConnectorGenerator.ConnectorArchitecture.ConnectorArchitecture;
import ConnectorGenerator.ConnectorArchitecture.ConnectorArchitecturePackage;
import ConnectorGenerator.ConnectorArchitecture.RoleMapping;

import ConnectorGenerator.ElementArchitecture.RealizedFeature;
import ConnectorGenerator.ElementArchitecture.RemoteBinding;
import ConnectorGenerator.ElementArchitecture.SubElement;

import java.util.Collection;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.common.util.EList;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;

import org.eclipse.emf.ecore.util.EObjectContainmentEList;
import org.eclipse.emf.ecore.util.InternalEList;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Connector Architecture</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link ConnectorGenerator.ConnectorArchitecture.impl.ConnectorArchitectureImpl#getCommunicationStyle <em>Communication Style</em>}</li>
 *   <li>{@link ConnectorGenerator.ConnectorArchitecture.impl.ConnectorArchitectureImpl#getUnits <em>Units</em>}</li>
 *   <li>{@link ConnectorGenerator.ConnectorArchitecture.impl.ConnectorArchitectureImpl#getBindings <em>Bindings</em>}</li>
 *   <li>{@link ConnectorGenerator.ConnectorArchitecture.impl.ConnectorArchitectureImpl#getName <em>Name</em>}</li>
 *   <li>{@link ConnectorGenerator.ConnectorArchitecture.impl.ConnectorArchitectureImpl#getFeatures <em>Features</em>}</li>
 *   <li>{@link ConnectorGenerator.ConnectorArchitecture.impl.ConnectorArchitectureImpl#getRoleMappings <em>Role Mappings</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class ConnectorArchitectureImpl extends FirstClassEntityImpl implements ConnectorArchitecture {
	/**
	 * The cached value of the '{@link #getCommunicationStyle() <em>Communication Style</em>}' reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getCommunicationStyle()
	 * @generated
	 * @ordered
	 */
	protected CommunicationStyle communicationStyle;

	/**
	 * The cached value of the '{@link #getUnits() <em>Units</em>}' containment reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getUnits()
	 * @generated
	 * @ordered
	 */
	protected EList<SubElement> units;

	/**
	 * The cached value of the '{@link #getBindings() <em>Bindings</em>}' containment reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getBindings()
	 * @generated
	 * @ordered
	 */
	protected EList<RemoteBinding> bindings;

	/**
	 * The default value of the '{@link #getName() <em>Name</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getName()
	 * @generated
	 * @ordered
	 */
	protected static final String NAME_EDEFAULT = null;

	/**
	 * The cached value of the '{@link #getName() <em>Name</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getName()
	 * @generated
	 * @ordered
	 */
	protected String name = NAME_EDEFAULT;

	/**
	 * The cached value of the '{@link #getFeatures() <em>Features</em>}' containment reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getFeatures()
	 * @generated
	 * @ordered
	 */
	protected EList<RealizedFeature> features;

	/**
	 * The cached value of the '{@link #getRoleMappings() <em>Role Mappings</em>}' containment reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getRoleMappings()
	 * @generated
	 * @ordered
	 */
	protected EList<RoleMapping> roleMappings;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected ConnectorArchitectureImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return ConnectorArchitecturePackage.Literals.CONNECTOR_ARCHITECTURE;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public CommunicationStyle getCommunicationStyle() {
		if (communicationStyle != null && communicationStyle.eIsProxy()) {
			InternalEObject oldCommunicationStyle = (InternalEObject)communicationStyle;
			communicationStyle = (CommunicationStyle)eResolveProxy(oldCommunicationStyle);
			if (communicationStyle != oldCommunicationStyle) {
				if (eNotificationRequired())
					eNotify(new ENotificationImpl(this, Notification.RESOLVE, ConnectorArchitecturePackage.CONNECTOR_ARCHITECTURE__COMMUNICATION_STYLE, oldCommunicationStyle, communicationStyle));
			}
		}
		return communicationStyle;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public CommunicationStyle basicGetCommunicationStyle() {
		return communicationStyle;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setCommunicationStyle(CommunicationStyle newCommunicationStyle) {
		CommunicationStyle oldCommunicationStyle = communicationStyle;
		communicationStyle = newCommunicationStyle;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, ConnectorArchitecturePackage.CONNECTOR_ARCHITECTURE__COMMUNICATION_STYLE, oldCommunicationStyle, communicationStyle));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<SubElement> getUnits() {
		if (units == null) {
			units = new EObjectContainmentEList<SubElement>(SubElement.class, this, ConnectorArchitecturePackage.CONNECTOR_ARCHITECTURE__UNITS);
		}
		return units;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<RemoteBinding> getBindings() {
		if (bindings == null) {
			bindings = new EObjectContainmentEList<RemoteBinding>(RemoteBinding.class, this, ConnectorArchitecturePackage.CONNECTOR_ARCHITECTURE__BINDINGS);
		}
		return bindings;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public String getName() {
		return name;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setName(String newName) {
		String oldName = name;
		name = newName;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, ConnectorArchitecturePackage.CONNECTOR_ARCHITECTURE__NAME, oldName, name));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<RealizedFeature> getFeatures() {
		if (features == null) {
			features = new EObjectContainmentEList<RealizedFeature>(RealizedFeature.class, this, ConnectorArchitecturePackage.CONNECTOR_ARCHITECTURE__FEATURES);
		}
		return features;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<RoleMapping> getRoleMappings() {
		if (roleMappings == null) {
			roleMappings = new EObjectContainmentEList<RoleMapping>(RoleMapping.class, this, ConnectorArchitecturePackage.CONNECTOR_ARCHITECTURE__ROLE_MAPPINGS);
		}
		return roleMappings;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
		switch (featureID) {
			case ConnectorArchitecturePackage.CONNECTOR_ARCHITECTURE__UNITS:
				return ((InternalEList<?>)getUnits()).basicRemove(otherEnd, msgs);
			case ConnectorArchitecturePackage.CONNECTOR_ARCHITECTURE__BINDINGS:
				return ((InternalEList<?>)getBindings()).basicRemove(otherEnd, msgs);
			case ConnectorArchitecturePackage.CONNECTOR_ARCHITECTURE__FEATURES:
				return ((InternalEList<?>)getFeatures()).basicRemove(otherEnd, msgs);
			case ConnectorArchitecturePackage.CONNECTOR_ARCHITECTURE__ROLE_MAPPINGS:
				return ((InternalEList<?>)getRoleMappings()).basicRemove(otherEnd, msgs);
		}
		return super.eInverseRemove(otherEnd, featureID, msgs);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case ConnectorArchitecturePackage.CONNECTOR_ARCHITECTURE__COMMUNICATION_STYLE:
				if (resolve) return getCommunicationStyle();
				return basicGetCommunicationStyle();
			case ConnectorArchitecturePackage.CONNECTOR_ARCHITECTURE__UNITS:
				return getUnits();
			case ConnectorArchitecturePackage.CONNECTOR_ARCHITECTURE__BINDINGS:
				return getBindings();
			case ConnectorArchitecturePackage.CONNECTOR_ARCHITECTURE__NAME:
				return getName();
			case ConnectorArchitecturePackage.CONNECTOR_ARCHITECTURE__FEATURES:
				return getFeatures();
			case ConnectorArchitecturePackage.CONNECTOR_ARCHITECTURE__ROLE_MAPPINGS:
				return getRoleMappings();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@SuppressWarnings("unchecked")
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case ConnectorArchitecturePackage.CONNECTOR_ARCHITECTURE__COMMUNICATION_STYLE:
				setCommunicationStyle((CommunicationStyle)newValue);
				return;
			case ConnectorArchitecturePackage.CONNECTOR_ARCHITECTURE__UNITS:
				getUnits().clear();
				getUnits().addAll((Collection<? extends SubElement>)newValue);
				return;
			case ConnectorArchitecturePackage.CONNECTOR_ARCHITECTURE__BINDINGS:
				getBindings().clear();
				getBindings().addAll((Collection<? extends RemoteBinding>)newValue);
				return;
			case ConnectorArchitecturePackage.CONNECTOR_ARCHITECTURE__NAME:
				setName((String)newValue);
				return;
			case ConnectorArchitecturePackage.CONNECTOR_ARCHITECTURE__FEATURES:
				getFeatures().clear();
				getFeatures().addAll((Collection<? extends RealizedFeature>)newValue);
				return;
			case ConnectorArchitecturePackage.CONNECTOR_ARCHITECTURE__ROLE_MAPPINGS:
				getRoleMappings().clear();
				getRoleMappings().addAll((Collection<? extends RoleMapping>)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case ConnectorArchitecturePackage.CONNECTOR_ARCHITECTURE__COMMUNICATION_STYLE:
				setCommunicationStyle((CommunicationStyle)null);
				return;
			case ConnectorArchitecturePackage.CONNECTOR_ARCHITECTURE__UNITS:
				getUnits().clear();
				return;
			case ConnectorArchitecturePackage.CONNECTOR_ARCHITECTURE__BINDINGS:
				getBindings().clear();
				return;
			case ConnectorArchitecturePackage.CONNECTOR_ARCHITECTURE__NAME:
				setName(NAME_EDEFAULT);
				return;
			case ConnectorArchitecturePackage.CONNECTOR_ARCHITECTURE__FEATURES:
				getFeatures().clear();
				return;
			case ConnectorArchitecturePackage.CONNECTOR_ARCHITECTURE__ROLE_MAPPINGS:
				getRoleMappings().clear();
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case ConnectorArchitecturePackage.CONNECTOR_ARCHITECTURE__COMMUNICATION_STYLE:
				return communicationStyle != null;
			case ConnectorArchitecturePackage.CONNECTOR_ARCHITECTURE__UNITS:
				return units != null && !units.isEmpty();
			case ConnectorArchitecturePackage.CONNECTOR_ARCHITECTURE__BINDINGS:
				return bindings != null && !bindings.isEmpty();
			case ConnectorArchitecturePackage.CONNECTOR_ARCHITECTURE__NAME:
				return NAME_EDEFAULT == null ? name != null : !NAME_EDEFAULT.equals(name);
			case ConnectorArchitecturePackage.CONNECTOR_ARCHITECTURE__FEATURES:
				return features != null && !features.isEmpty();
			case ConnectorArchitecturePackage.CONNECTOR_ARCHITECTURE__ROLE_MAPPINGS:
				return roleMappings != null && !roleMappings.isEmpty();
		}
		return super.eIsSet(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public String toString() {
		if (eIsProxy()) return super.toString();

		StringBuffer result = new StringBuffer(super.toString());
		result.append(" (name: ");
		result.append(name);
		result.append(')');
		return result.toString();
	}

} //ConnectorArchitectureImpl
